const http = require('http');
const fs = require('fs');

http.createServer((req,res)=>{
  let rs = fs.createReadStream(`www${req.url}`);
  rs.pipe(res);
  rs.on('error',(err)=> {
    res.writeHeader(404);
    res.write('is not found');
    res.end();
  });
  res.on('finish',()=> {
    console.log('传输完成！');
    res.end();
  });
}).listen(8080);
